﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using DoAnWeb.BUS;
using DoAnWeb.DAO;
using DoAnWeb.DTO;
namespace DoAnWeb
{
    public partial class TopDeal : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
             if (!IsPostBack)
            {
                LoadDanhSach();
            }

        }

        protected bool TinhTrang(int _MaTinKhuyenMai)
        {
            int SoLuongConLai = new TinKhuyenMaiBUS().CountNumberRemain(_MaTinKhuyenMai);
            if (SoLuongConLai <= 0)
                return false;
            else
                return true;
        }

        protected string SoLuotThamGia(int _MaTinKhuyenMai)
        {
            int SoLuot = new TinKhuyenMaiBUS().CountNumberSelled(_MaTinKhuyenMai);
            if (SoLuot <= 0)
                return "Hãy là người đầu tiên.";
            else
                return SoLuot.ToString() + " lượt.";
        }

        void LoadDanhSach()
        {
            dlDanhSach.DataSource = new TinKhuyenMaiBUS().GetList_Top();
            dlDanhSach.DataBind();
        } 
    }
}